const router = require('koa-router')() // 一边导入一边实例化
// 操作数据库的接口
const { getToken, Queryurl } = require('../../config/databaseapi.js')
// 注册接口
router.post('/queryalltopic', async (ctx) => {
	console.log('调用查询帖子接口');
	const queryParams = {};
	for(let key in ctx.request.body){
		if(key!=="pageNo" && ctx.request.body[key]!==""){
			queryParams[key] = ctx.request.body[key];
		}
	}
	console.log(queryParams);
	const res = await new getToken().posteve(Queryurl,`db.collection("topic").where(${JSON.stringify(queryParams)}).skip(${(ctx.request.body.pageNo-1)*10}).get()`);
	console.log(res);
	ctx.body = res;
})

module.exports = router.routes()